<?php
/*
 Social web links option page
*/
/** DO NOT MODIFY THIS FILE **/
global $imgdir, $customdir, $customurl, $social_web_link_options;
$message = "";

if(isset($_POST['delete_settings_submit'])) {
    delete_option('social_web_link_options');
    $message = '<div class="success">'.__('Default Settings Restored','social-web-links').'</div>';
}

$icon_array = get_social_web_icons("size_32");
get_social_web_links_settings();
if(isset($_POST['save_settings_submit'])) {
    foreach($icon_array as $social) {
        $postvar = 'social_'.$social['name'].'_in';
        if(preg_match('/http:/',trim($_POST[$postvar])) <= 0 and trim($_POST[$postvar] != ""))
            $_POST[$postvar] = 'http://'.trim($_POST[$postvar]);
        $social_web_link_options[$social['name']] = trim($_POST[$postvar]);
    }
    $social_web_link_options['icon_size'] = trim($_POST['social_icon_size_in']);
    $social_web_link_options['display_style'] = trim($_POST['social_icon_display_in']);
    $social_web_link_options['show_names'] = $_POST['show_names_in'];
    $social_web_link_options['enable_bookmarks'] = $_POST['enable_bookmarks_in'];
    $social_web_link_options['bookmark_icon_size'] = trim($_POST['bookmark_icon_size_in']);
    update_option('social_web_link_options',$social_web_link_options);
    $message = '<div class="success">'.__('Settings Saved').'</div>';
}

?>

<!-- Option form starts -->
<h1 class="socialadmintitle"><?php _e('Social Web Links Settings','social-web-links'); ?></h1>
<div class="socialadminsection">
    <h3><?php _e('Instructions on how to use custom icons','social-web-links'); ?></h3>
    <p><?php _e('Incase you don\'t like these default icons, you can replace them with your own set of icons in following way:','social-web-links'); ?></p>
    <ol>
        <li><?php _e('After you activated the plugin, go to your uploads directory i.e. wp-content/uploads and you shall see a folder for social_web_links_icons','social-web-links'); ?></li>
        <li><?php _e('Inside social_web_links_icons folder, you shall see three folders for different sizes of icons 16x16, 32x32 and 48x48','social-web-links'); ?></li>
        <li><?php _e('Drop your new icons in the respective size folder, Note: You should have the same file name as what the default icon has. e.g. if Facebook default icon is facebook.png then your new icon should also be named as facebook.png','social-web-links'); ?></li>
        <li><?php _e('Note as of now, this plugin only supports PNG images','social-web-links'); ?></li>
    </ol>
    <form name="socialaddprofileform" id="socialaddprofileform" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>#socialaddprofileform">
        <span id="message"><?php echo $message; ?></span>
        <h3><?php _e('Select the size of icons to display','social-web-links'); ?></h3>
        <p>
            <label><?php _e('Icon size:','social-web-links'); ?></label>
            <select name="social_icon_size_in" id="social_icon_size_in">
                <option value="size_16" <?php if($social_web_link_options['icon_size'] == "size_16") echo 'selected="selected"'; ?>><?php _e('16x16px','social-web-links'); ?></option>
                <option value="size_24"<?php if($social_web_link_options['icon_size'] == "size_24") echo 'selected="selected"'; ?>><?php _e('24x24px','social-web-links'); ?></option>
                <option value="size_32"<?php if($social_web_link_options['icon_size'] == "size_32") echo 'selected="selected"'; ?>><?php _e('32x32px','social-web-links'); ?></option>
                <option value="size_48" <?php if($social_web_link_options['icon_size'] == "size_48") echo 'selected="selected"'; ?>><?php _e('48x48px','social-web-links'); ?></option>
            </select>
        </p>
        <h3><?php _e('Select the style of display','social-web-links'); ?></h3>
        <p>
            <label><?php _e('Display style:','social-web-links'); ?></label>
            <select name="social_icon_display_in" id="social_icon_display_in">
                <option value="horizontal" <?php if($social_web_link_options['display_style'] == "horizontal") echo 'selected="selected"'; ?>><?php _e('Horizontal','social-web-links'); ?></option>
                <option value="vertical_one"<?php if($social_web_link_options['display_style'] == "vertical_one") echo 'selected="selected"'; ?>><?php _e('One Column Vertical','social-web-links'); ?></option>
                <option value="vertical_two" <?php if($social_web_link_options['display_style'] == "vertical_two") echo 'selected="selected"'; ?>><?php _e('Two Column Vertical','social-web-links'); ?></option>
            </select>
        </p>
        <p><label><?php _e('Display names besides icons ?'); ?></label> <input type="checkbox" name="show_names_in" id="show_names_in" value="true" <?php if($social_web_link_options['show_names']) echo "checked"; ?> /></p>
        <p><i><?php _e('Names can be displayed only for vertical display style','social-web-links'); ?></i></p>
        <h3><?php _e('Post bookmarking feature','social-web-links'); ?></h3>
        <p><label><?php _e('Enable post bookmarking','social-web-links'); ?></label> <input type="checkbox" name="enable_bookmarks_in" id="enable_bookmarks_in" value="true" <?php if($social_web_link_options['enable_bookmarks']) echo "checked"; ?> /></p>
        <p>
            <label><?php _e('Bookmark Icon size:','social-web-links'); ?></label>
            <select name="bookmark_icon_size_in" id="bookmark_icon_size_in">
                <option value="size_16" <?php if($social_web_link_options['bookmark_icon_size'] == "size_16") echo 'selected="selected"'; ?>><?php _e('16x16px','social-web-links'); ?></option>
                <option value="size_24"<?php if($social_web_link_options['bookmark_icon_size'] == "size_24") echo 'selected="selected"'; ?>><?php _e('24x24px','social-web-links'); ?></option>
                <option value="size_32"<?php if($social_web_link_options['bookmark_icon_size'] == "size_32") echo 'selected="selected"'; ?>><?php _e('32x32px','social-web-links'); ?></option>
                <option value="size_48" <?php if($social_web_link_options['bookmark_icon_size'] == "size_48") echo 'selected="selected"'; ?>><?php _e('48x48px','social-web-links'); ?></option>
            </select>
        </p>
        <h3><?php _e('Enter your user profile URLs for the sites you want to display','social-web-links'); ?></h3>
        <p><i><?php _e('For profiles whose URLs are left empty, those won\'t be displayed','social-web-links'); ?></i></p> 
        <table class="socialtablayout" border="1">
            <tr>
            <?php
                $count = 1;
                foreach($icon_array as $social) {
                    if($social['name'] != "email") :
            ?>
                <td>
                    <label style="cursor: default;"><img style="vertical-align:middle;" src="<?php echo $social['icon_url']; ?>" /> <?php echo ucwords($social['name']); ?></label>
                    <input type="text" name="social_<?php echo $social['name']; ?>_in" id="social_<?php echo $social['name']; ?>_in" value="<?php echo $social_web_link_options[$social['name']]; ?>" />
                </td>
            <?php
                        if($count % 3 == 0) echo '</tr><tr>';
                    $count++;
                    endif;
                }
            ?>
            </tr>
        </table>
        <br />
        <input type="submit" class="btn" name="save_settings_submit" id="save_settings_submit" value="<?php _e('Save Settings','social-web-links'); ?>" />
        <input type="submit" style="margin-left: 20px;" class="btn" name="delete_settings_submit" id="delete_settings_submit" value="<?php _e('Restore Default Settings','social-web-links'); ?>" /> <?php _e('Note: This will delete the saved profile URLs as well','social-web-links'); ?>
    </form>
</div>